{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#18连锁经营专业不同性别消费对比图\n",
    "import pandas as pd \n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "major=data1[data1['Major']=='18连锁经营']\n",
    "majorman=major[major['Sex']=='男']\n",
    "majorwoman=major[major['Sex']=='女']\n",
    "\n",
    "\n",
    "dupe=majorman.duplicated('CardNo')\n",
    "totalpeople=majorman['CardNo'].count()-sum(dupe)\n",
    "totalpeople\n",
    "meanspend=sum(majorman['Money'])/totalpeople #人均消费\n",
    "print('18连锁经营男生人均消费',meanspend)\n",
    "\n",
    "dupe=majorwoman.duplicated('CardNo')\n",
    "totalpeople=majorwoman['CardNo'].count()-sum(dupe)\n",
    "totalpeople\n",
    "meanspend1=sum(majorwoman['Money'])/totalpeople #人均消费\n",
    "print('18连锁经营女生人均消费',meanspend1)\n",
    "\n",
    "l1=['男','女']\n",
    "l2=[meanspend,meanspend1]\n",
    "s1=pd.Series(l2,index=l1)\n",
    "matplotlib.rcParams['font.sans-serif']=['SimHei']\n",
    "s1.plot.bar(x=l1,y=l2)\n",
    "plt.title('18连锁经营专业不同性别消费对比图')\n",
    "plt.savefig('18连锁经营专业不同性别消费对比图.jpg')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
